package com.micosco.taskremind.data;

import java.time.LocalDateTime;
import java.util.List;

public class TaskDAOProxy implements TaskDAO {
    private TaskDAO target;

    public TaskDAOProxy(TaskDAO target) {
        this.target = target;
    }

    @Override
    public void add(Task task) {
        task.setLastModify(LocalDateTime.now());
        target.add(task);
    }

    @Override
    public void remove(Task task) {
        target.remove(task);
    }

    @Override
    public void update(Task... task) {
        for (Task e : task) {
            e.setLastModify(LocalDateTime.now());
        }
        target.update(task);
    }

    @Override
    public List<Task> findByID(int taskID) {
        return target.findByID(taskID);
    }

    @Override
    public List<Task> findAllUnfinished() {
        return target.findAllUnfinished();
    }

    @Override
    public List<Task> findAll() {
        return target.findAll();
    }
}
